package com.rgs.base.database.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;


@tk.mybatis.mapper.annotation.RegisterMapper
public interface SelectExtendMapper<T> {
    @SelectProvider(type = BaseSelectExtendProvider.class, method = "dynamicSQL")
    List<T> selectSumGroupBy(@Param("sumColumnList") List<String> sumColumnList,
                             @Param("groupByList") List<String> groupByList,
                             @Param("example") Object example,
                             @Param("maxColumnList") List<String> maxColumnList);

    @SelectProvider(type = BaseSelectExtendProvider.class, method = "dynamicSQL")
    List<T> selectSumGroupByWithForceIndex(@Param("sumColumnList") List<String> sumColumnList,
                                           @Param("groupByList") List<String> groupByList,
                                           @Param("example") Object example,
                                           @Param("maxColumnList") List<String> maxColumnList,
                                           @Param("forceIndexList") List<String> forceIndexList);

    /**
     * 汇总报表查询
     *
     * @param sumColumnList 需要汇总的列
     * @param groupByList   需要groupBy的列
     * @param example       查询条件
     * @param maxColumnList 不在groupBy的列，需要显示的字段
     * @param orderByList   排序的字段
     * @param customSql     拼接sql
     * @return java.util.List<T>
     * @author daxiong
     * @date 2021/4/29 上午10:19
     */
    @SelectProvider(type = BaseSelectExtendProvider.class, method = "dynamicSQL")
    List<T> selectSumGroupByFull(@Param("sumColumnList") List<String> sumColumnList,
                                 @Param("groupByList") List<String> groupByList,
                                 @Param("example") Object example,
                                 @Param("maxColumnList") List<String> maxColumnList,
                                 @Param("orderByList") List<String> orderByList,
                                 @Param("customSql") List<String> customSql);


    /**
     * 汇总报表查询
     *
     * @param sumColumnList 需要汇总的列
     * @param countAlias    count(1)的别名
     * @param groupByList   需要groupBy的列
     * @param example       查询条件
     * @param maxColumnList 不在groupBy的列，需要显示的字段
     * @param orderByList   排序的字段
     * @param customSql     拼接sql
     * @return java.util.List<T>
     * @author daxiong
     * @date 2021/4/29 上午10:19
     */
    @SelectProvider(type = BaseSelectExtendProvider.class, method = "dynamicSQL")
    List<T> selectSumGroupByFullWithCount(@Param("sumColumnList") List<String> sumColumnList,
                                          @Param("countAlias") String countAlias,
                                          @Param("groupByList") List<String> groupByList,
                                          @Param("example") Object example,
                                          @Param("maxColumnList") List<String> maxColumnList,
                                          @Param("orderByList") List<String> orderByList,
                                          @Param("customSql") List<String> customSql);

}
